
<%@ page import="com.capgemini.rdlgae.domain.Commande"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="layout" content="main" />
<g:set var="entityName"
	value="${message(code: 'commande.label', default: 'Commande')}" />
<title><g:message code="default.create.label"
	args="[entityName]" /></title>
<g:javascript library="prototype" />
</head>
<body>
<div class="nav"><span class="menuButton"><g:link
	class="list" action="list">
	<g:message code="default.list.label" args="[entityName]" />
</g:link></span></div>
<div class="body">
<h1><g:message code="default.create.label" args="[entityName]" /></h1>
<g:if test="${flash.message}">
	<div class="message">
	${flash.message}
	</div>
</g:if> <g:hasErrors bean="${commandeInstance}">
	<div class="errors"><g:renderErrors bean="${commandeInstance}"
		as="list" /></div>
</g:hasErrors> <g:form action="save" method="post">
	<div class="dialog">
	<table>
		<tbody>

			<tr class="prop">
				<td valign="top" class="name"><label for="dateCommande"><g:message
					code="commande.dateCommande.label" default="Date Commande" /></label></td>
				<td valign="top"
					class="value ${hasErrors(bean: commandeInstance, field: 'dateCommande', 'errors')}">
				<g:datePicker name="dateCommande" precision="day"
					value="${commandeInstance?.dateCommande}" /></td>
			</tr>

			<tr class="prop">
				<td valign="top" class="name"><label for="entree"><g:message
					code="commande.entree.label" default="Entree" /></label></td>
				<td valign="top"
					class="value ${hasErrors(bean: commandeInstance, field: 'entree', 'errors')}">
				<g:select name="entree.id" from="${entrees}" optionKey="id"
					value="${commandeInstance?.entree?.id}" noSelection="['':'']"
					onchange="updatePrix()" /></td>
			</tr>

			<tr class="prop">
				<td valign="top" class="name"><label for="plat"><g:message
					code="commande.plat.label" default="Plat" /></label></td>
				<td valign="top"
					class="value ${hasErrors(bean: commandeInstance, field: 'plat', 'errors')}">
				<g:select name="plat.id" from="${plats}" optionKey="id"
					value="${commandeInstance?.plat?.id}" onchange="updatePrix()" /></td>
			</tr>

			<tr class="prop">
				<td valign="top" class="name"><label for="dessert"><g:message
					code="commande.dessert.label" default="Dessert" /></label></td>
				<td valign="top"
					class="value ${hasErrors(bean: commandeInstance, field: 'dessert', 'errors')}">
				<g:select name="dessert.id" from="${desserts}" optionKey="id"
					value="${commandeInstance?.dessert?.id}" noSelection="['':'']"
					onchange="updatePrix()" /></td>
			</tr>

			<tr class="prop">
				<td valign="top" class="name"><label for="commentaire"><g:message
					code="commande.commentaire.label" default="Commentaire" /></label></td>
				<td valign="top"
					class="value ${hasErrors(bean: commandeInstance, field: 'commentaire', 'errors')}">
				<g:textField name="commentaire" id="commentaire" /></td>
			</tr>
			<tr class="prop">
				<td valign="top" class="name"><label for="utilisateur"><g:message
					code="commande.utilisateur.label" default="Utilisateur" /></label></td>
				<td valign="top"
					class="value ${hasErrors(bean: commandeInstance, field: 'utilisateur', 'errors')}">
				<g:select name="utilisateur.id" from="${utilisateurs}"
					optionKey="id" value="${commandeInstance?.utilisateur?.id}" /></td>
			</tr>

			<tr class="prop">
				<td valign="top" class="name"><label for="total"><g:message
					code="commande.total.label" default="Total" /></label></td>
				<td valign="top"
					class="value ${hasErrors(bean: commandeInstance, field: 'total', 'errors')}">
				<div name="total" id="total"></div>
				</td>
			</tr>

		</tbody>
	</table>
	</div>
	<div class="buttons"><span class="button"><g:submitButton
		name="create" class="save"
		value="${message(code: 'default.button.create.label', default: 'Create')}" /></span>
	</div>
	<g:javascript>
	function updatePrix(){	
		${remoteFunction(action:'calculerTotal', params:'\'idEntree=\'+ document.getElementById(\'entree.id\').value +\'&idPlat=\'+ document.getElementById(\'plat.id\').value+\'&idDessert=\'+ document.getElementById(\'dessert.id\').value', update:'total', onFailure:'alert(\'erreur\')')}
	}
	updatePrix();
	</g:javascript>
</g:form></div>
</body>
</html>
